home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 February / SGI IRIX 6.5 Complementary Applications 2004 February.iso / dist / cde.idb / usr / dt / share / examples / dtksh / TextCutBuf1.z / TextCutBuf1
Encoding:
Text File  |  2003-11-18  |  3.8 KB  |  137 lines

  1. #! /usr/dt/bin/dtksh
  2. #
  3. # TextCutBuf1
  4. #
  5. # Copyright 2000, Silicon Graphics, Inc.
  6. # ALL RIGHTS RESERVED
  7. # UNPUBLISHED -- Rights reserved under the copyright laws of the United
  8. # States.   Use of a copyright notice is precautionary only and does not
  9. # imply publication or disclosure.
  10. #
  11. # U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  12. # Use, duplication or disclosure by the Government is subject to restrictions
  13. # as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  14. # in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  15. # in similar or successor clauses in the FAR, or the DOD or NASA FAR
  16. # Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  17. # 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  18. #
  19. # THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  20. # INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  21. # DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  22. # PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  23. # GRAPHICS, INC.
  24. #
  25. ##########################################################################
  26. #  (c) Copyright 1993, 1994 Hewlett-Packard Company    
  27. #  (c) Copyright 1993, 1994 International Business Machines Corp.
  28. #  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  29. #  (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  30. #      Novell, Inc.
  31. ##########################################################################
  32.  
  33.  
  34. #
  35. # This sample shell script demonstrates how the Text cut, copy and paste
  36. # facilities work.
  37. #
  38.  
  39. # Pushbutton Callback: cut the currently select text
  40. Cut()
  41. {
  42.    if XmTextCut $TEXT $(XtLastTimestampProcessed "-" $(XtDisplay "-" $TEXT)); 
  43.    then
  44.       echo "Cut occurred"
  45.    else
  46.       echo "No primary selection"
  47.    fi
  48. }
  49.  
  50. # Pushbutton Callback: copy the currently select text
  51. Copy()
  52. {
  53.    if XmTextCopy $TEXT $(XtLastTimestampProcessed "-" $(XtDisplay "-" $TEXT)); 
  54.    then
  55.       echo "Copy occurred"
  56.    else
  57.       echo "No primary selection"
  58.    fi
  59. }
  60.  
  61. # Pushbutton Callback: clear the text selection
  62. ClearSelection()
  63. {
  64.    XmTextClearSelection $TEXT $(XtLastTimestampProcessed "-" $(XtDisplay "-" $TEXT))
  65. }
  66.  
  67. # Pushbutton Callback: paste the cut buffer at the current insertion position
  68. Paste()
  69. {
  70.    if XmTextPaste $TEXT; then
  71.       echo "Paste occurred"
  72.    else
  73.       echo "No primary selection"
  74.    fi
  75. }
  76.  
  77.  
  78. ######################### Create the Main UI #################################
  79.  
  80. XtInitialize TOPLEVEL textCutBuf1 TextCutBuf1 "$0" "$@"
  81. XtSetValues $TOPLEVEL allowShellResize:True
  82.  
  83. XtCreateManagedWidget FORM form XmForm $TOPLEVEL \
  84.  
  85. XtCreateManagedWidget TEXT text XmText $FORM \
  86.     topAttachment:ATTACH_FORM \
  87.     topOffset:10 \
  88.     leftAttachment:ATTACH_FORM \
  89.     leftOffset:10 \
  90.     rightAttachment:ATTACH_FORM \
  91.     rightOffset:10 \
  92.     columns:40 \
  93.     value:"This is the default string"
  94.  
  95. XtCreateManagedWidget TEXT2 text2 XmText $FORM \
  96.     topAttachment:ATTACH_WIDGET \
  97.     topWidget:$TEXT \
  98.     topOffset:10 \
  99.     leftAttachment:ATTACH_FORM \
  100.     leftOffset:10 \
  101.     rightAttachment:ATTACH_FORM \
  102.     rightOffset:10 \
  103.     bottomAttachment:ATTACH_FORM \
  104.     bottomOffset:10 \
  105.     columns:40 \
  106.     editable:False
  107.  
  108. XtRealizeWidget $TOPLEVEL
  109.  
  110. XtCreateApplicationShell TOPLEVEL2 textCutBuf1a TopLevelShell
  111.  
  112. XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
  113.          orientation:HORIZONTAL \
  114.          numColumns:2 \
  115.          packing:PACK_COLUMN 
  116.  
  117. XtCreateManagedWidget PB1 pb1 XmPushButton $RC \
  118.     labelString:"Cut Selection"
  119. XtAddCallback $PB1 activateCallback "Cut"
  120.  
  121. XtCreateManagedWidget PB2 pb2 XmPushButton $RC \
  122.     labelString:"Copy Selection"
  123. XtAddCallback $PB2 activateCallback "Copy"
  124.  
  125. XtCreateManagedWidget PB3 pb3 XmPushButton $RC \
  126.     labelString:"Paste"
  127. XtAddCallback $PB3 activateCallback "Paste"
  128.  
  129. XtCreateManagedWidget PB4 pb4 XmPushButton $RC \
  130.     labelString:"Clear Selection"
  131. XtAddCallback $PB4 activateCallback "ClearSelection"
  132.  
  133. XtRealizeWidget $TOPLEVEL2
  134.  
  135. XtMainLoop
  136.